package com.luweijie.sh.controller;


import com.luweijie.entity.vo.Result;

import com.luweijie.sh.entity.po.Resource;
import com.luweijie.sh.service.IResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Set;

/**
 * <p>
 * 资源表 前端控制器
 * </p>
 *
 * @author luweijie
 * @since 2020-06-11
 */
@RestController
@RequestMapping("/resource")
public class ResourceController {

    @Autowired
    IResourceService resourceService;

    @GetMapping("/query")
    public Result allResource(String role){
        List<Resource> query = resourceService.query(role);
       return Result.success(query);
    }
    @GetMapping("/all")
    public Result<Set<Resource>> all(){
        List<Resource> all = resourceService.all();
        return Result.success(all);
    }

    @GetMapping(value = "/user/{username}")
    Result resources(@PathVariable("username") String username){
        List<Resource> query = resourceService.query(username);
        return Result.success(query);
    }
}
